//
// File: mpower.cpp
//
// MATLAB Coder version            : 4.0
// C/C++ source code generated on  : 18-Dec-2020 16:50:24
//

// Include Files
#include <cmath>
#include "rt_nonfinite.h"
#include "sea_parameter_cal.h"
#include "mpower.h"

// Function Definitions

//
// Arguments    : const double a[4]
//                double c[4]
// Return Type  : void
//
void mpower(const double a[4], double c[4])
{
  double r;
  double t;
  if (std::abs(a[1]) > std::abs(a[0])) {
    r = a[0] / a[1];
    t = 1.0 / (r * a[3] - a[2]);
    c[0] = a[3] / a[1] * t;
    c[1] = -t;
    c[2] = -a[2] / a[1] * t;
    c[3] = r * t;
  } else {
    r = a[1] / a[0];
    t = 1.0 / (a[3] - r * a[2]);
    c[0] = a[3] / a[0] * t;
    c[1] = -r * t;
    c[2] = -a[2] / a[0] * t;
    c[3] = t;
  }
}

//
// File trailer for mpower.cpp
//
// [EOF]
//
